<?php
/**
 * Created by xiaosong
 * E-mail:4155433@gmail.com
 * Date: 2019/8/3
 * Time: 14:36
 */

namespace app\common\model;


use think\Model;

class OrderRecord extends Model
{

    public function getTypeTextAttr($value,$data)
    {
        $status = [0=>'弃单',1=>'正常派单'];
        return $status[$data['type']];
    }

    public function getStatusTextAttr($value,$data)
    {
        $status = [0=>'进行中',1=>'派单结束'];
        return $status[$data['status']];
    }

    public function getList($where = []){
        return $this->alias('a')
            ->where($where)
            ->join([
                ['users u','a.user_id = u.user_id','left'],
                ['room r','a.room_id = r.room_id','left'],
            ])
            ->order('a.id desc')
            ->field('a.*,u.nick_name,r.room_name')
            ->cache()
            ->paginate('',false,['query'=>request()->param()]);
    }


}